package com.example.springevent.listener;

import com.example.springevent.event.OrderCreatedEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

/**
 * 订单事件监听器 - 实现ApplicationListener接口
 */
@Slf4j
@Component
public class OrderEventListener implements ApplicationListener<OrderCreatedEvent> {
    
    @Override
    public void onApplicationEvent(OrderCreatedEvent event) {
        log.info("收到订单创建事件: 订单号 = {}, 金额 = {}", 
                event.getOrder().getOrderNumber(), 
                event.getOrder().getAmount());
        
        // 这里可以执行订单后续处理逻辑
        log.info("处理新订单: {}", event.getOrder().getOrderNumber());
    }
}